<template>
    <div class="container">
        <div class="dispatch-order">
            <header>
                <router-link to="/">首页 / </router-link>
                已派订单
            </header>
            <div v-if="messageList.length > 0" class="focus-pointer mb30">
                <div class="flex-box-align" style="padding-left: 18px; position: relative; width: 100%;">
                    今日要事：
                    <div class="message">
                        <ul class="marquee_list" :style="{ top: -num + 'px'}" :class="{marquee_top:num}">
                            <li v-for="(item, index) in messageList" :key="index" v-if="messageList && messageList.length">
                                <router-link :to="{name: item.route}">{{item.showMsg}}</router-link>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <ul class="company-num-list flex-box-align mb30">
                <li class="flex">
                    <div class="li-top">今日新派订单</div>
                    <div>{{returnPrice(info.orderBankDayNew)}}</div>
                </li>
                <li class="flex">
                    <div class="li-top">已完成订单量</div>
                    <div>{{returnPrice(info.orderBankCountFinished)}}</div>
                </li>
                <li class="flex">
                    <div class="li-top">已发放金额</div>
                    <div>{{returnPrice(info.orderBankAmountFinished)}}</div>
                </li>
                <li class="flex">
                    <div class="li-top">累计已派订单</div>
                    <div>{{returnPrice(info.orderBankCountTotal)}}</div>
                </li>
            </ul>
            <div class="search-modal mb30">
                <div class="" style="margin-bottom: 20px">
                    <span>查询</span>
                    <el-button type="primary" size="small" @click="handleClickSearch">查询</el-button>
                </div>
                <div class="flex-box-align">
                    <div class="search-item">
                        <div class="search-title">资方：</div>
                        <el-select filterable v-model="configList.param.bankId" placeholder="请选择">
                            <el-option
                                    label="全部"
                                    value="">
                            </el-option>
                            <el-option
                                    v-for="item in bankList"
                                    :key="item.id"
                                    :label="item.bankName"
                                    :value="item.id">
                            </el-option>
                        </el-select>

                    </div>
                    <div class="search-item flex-box-align" style="">
                        <span class="search-title">产品：</span>
                        <el-select filterable v-model="configList.param.productId" placeholder="请选择">
                            <el-option
                                    label="全部"
                                    value="">
                            </el-option>
                            <el-option
                                    v-for="item in productList"
                                    :key="item.productId"
                                    :label="item.productName"
                                    :value="item.productId">
                            </el-option>
                        </el-select>
                    </div>
                    <div class="search-item">
                        <div class="search-title">企业：</div>
                        <el-select filterable v-model="configList.param.userId" placeholder="请选择">
                            <el-option
                                    label="全部"
                                    value="">
                            </el-option>
                            <el-option
                                    v-for="item in companyList"
                                    :key="item.userId"
                                    :label="item.companyName"
                                    :value="item.userId">
                            </el-option>
                        </el-select>
                    </div>
                    <div class="search-item">
                        <div class="search-title">阶段：</div>
                        <el-select filterable v-model="configList.param.stepKey" placeholder="请选择">
                            <el-option
                                    label="全部"
                                    value="">
                            </el-option>
                            <el-option
                                    v-for="item in stepList"
                                    :key="item.stepKey"
                                    :label="item.stepName"
                                    :value="item.stepKey">
                            </el-option>
                        </el-select>
                    </div>
                </div>
            </div>

            <div class="">
                <table-list ref="tableList" :tableConfig='configList'>
                    <el-table-column  slot=""  align="center" label="">
                        <template slot-scope="scope">
                            <span></span>
                        </template>
                    </el-table-column>
                    <el-table-column class="btn" label="操作" slot="btn" align="center" >
                        <template slot-scope="scope">
                            <el-button  @click="$router.push('/check/sentOrderDetail?orderId='+scope.row.orderId)" type="primary" size="small" style="background: #ED7018;border-color: #ED7018">跟进</el-button>
                        </template>
                    </el-table-column>
                </table-list>
            </div>
        </div>
    </div>
</template>

<script>
    import {parseUrlParams} from "../../util";
    let CONSTANT = require('../../constant/constant.js'),
        common = require('../../common.js');
    export default {
        data() {
            return {
                info:'',
                configList:{
                    url:CONSTANT.URL.ORDER.DISPATCHORDERLIST,
                    configList:[
                        {
                            label:'订单号',
                            prop: "orderId"
                        },
                        {
                            label:'来源订单',
                            prop: "masterOrderId"
                        },
                        {
                            label:'企业',
                            prop: "masterOrder.coreData.companyName"
                        },
                        {
                            label:'贷款产品',
                            prop: "masterOrder.productData.productName"
                        },
                        {
                            slot: "name"
                        },
                        {
                            label:'资方业务经理',
                            prop: "bankServiceManagerName"
                        },
                        {
                            label:'融资顾问',
                            prop: "masterOrder.adviserName"
                        },
                        {
                            label:'派单人',
                            prop: "dispatchAdminName"
                        },
                        {
                            label:'派单时间',
                            prop: "gmtCreated"
//                            dispatchTime
                        },
                        {
                            label:'阶段',
                            prop: "stepName"
                        },
                        {
                            slot:'btn'
                        }
                    ],
                    param:{
                        bankId: "",
//                        notStepKeys: [],
                        productId: "",
                        stepKey: "",
                        userId: "",
//                        userIds: [],
                    },
                    type:'',
                    width:'',
                    isPagination:true
                },
                bankList: [],
                companyList: [],
                stepList: [],
                productList: [],
                num: 0,
                messageList: []
            }
        },
        mounted(){
            this.getMessage()
            setInterval( () => {
                this.getMessage()
            }, 120000)
            this.getUserType("company", "", (data) => {
                this.companyList = data.data.bussData
            })
            this.getBankUserList()
            this.getOrderStepList()
            this.getAllProduct()
            this.getTotal()
        },
        components: {
            'table-list':() => import('../common/my-table')
        },
        methods:{
            getMessage() {
                let url = CONSTANT.URL.CALENDAR.MESSAGELIST;
                common.requestAjax(url, {}, {}, (data) => {
                    if(data.status == 200) {
                        this.messageList = data.data.bussData;
                        this.showMarquee(this.num)
                    }
                })
            },
            returnPrice(num){
                return common.returnNum(num)
            },
            getList() {
                for (let i in this.configList.param) {
                    if (!this.configList.param[i]) {
                        delete this.configList.param[i]
                    }
                }
                this.$refs.tableList.getList()
            },
            getOrderStepList() {
                let url = CONSTANT.URL.ORDER.ORDERSTEPLIST;
                common.requestAjax(url, {}, {}, (data) => {
                    this.stepList = data.data.bussData
                })
            },
            getAllProduct() {
                let url = CONSTANT.URL.FINANCE.PRODUCTALL;
                common.requestAjax(url, {}, {}, (data) => {
                    this.productList = data.data.bussData
                })
            },
            getBankUserList() {
                let url = CONSTANT.URL.COMPANY.BANKUSERTREE;
                common.requestAjax(url, {}, {}, (data) => {
                    this.bankList = data.data.bussData;
                })
            },
            getUserType(params, secondParams, callback) {
                let url = CONSTANT.URL.COMPANY.USERTYPE;
                common.requestAjax(url, JSON.stringify({userType: params, capitalType: secondParams}), {}, callback)
            },
            getTotal() {
                let url = CONSTANT.URL.REPORT.FINDORDERBANKREPORTDATA,
                data = {};
                common.requestAjax(url, JSON.stringify(data), {}, (data) => {
                    if (data.status == 200) {
                        this.info = data.data.bussData;
                    }
                })
            },
            handleClickSearch() {
                this.getList()
            },
            handleChangeBankTree(val) {

            },
            showMarquee:function (num) {
                if (!this.messageList[0]) return
                this.messageList.push(this.messageList[0]);
                var max = this.messageList.length;
                var that = this;
                let marqueetimer =  setInterval(function(){
                    num++;
                    if(num>=max ){
                        num=0;
                    }
                    that.num=num*30;
                }, 2000);
            }
        }
    }
</script>

<style lang="scss">
    .message {
        display: block;
        position: relative;
        width: 60%;
        height: 30px;/*关键样式*/
        overflow: hidden;
    }
    .marquee_list{
        display: block;
        position: absolute;
        top:0;
        left: 0;
    }
    .marquee_top{transition: top 0.5s ;}/*关键样式*/
    .marquee_list li{
        height: 30px;/*关键样式*/
        line-height: 30px;/*关键样式*/
        font-size: 14px;
        padding-left: 20px;
        background-color: #fff;
        a {
            color: #333;
        }
    }
    .container {
        .mb30 {
            margin-bottom: 30px;
        }
        .dispatch-order {
            header {
                margin: 19px 0;
                font-size: 14px;
                color: #333;
                a {
                    color: #999;
                }
            }
            .focus-pointer {
                font-size: 14px;
                height: 70px;
                line-height: 70px;
                background-color: #fff;
                padding-left: 18px;
                white-space: nowrap;
            }
            /*
            .company-num-list {
                li {
                    flex: 1;
                    cursor: pointer;
                   height: 152px;
                    padding-top: 48px;
                    background-color: #fff;
                    box-shadow:2px 0px 1px rgba(15,5,9,0.1);
                    margin-right: 1.3%;
                    &:last-child {
                        margin-right: 0;
                    }
                    div:nth-child(1) {
                        font-size: 60px;
                        color: #111111;
                        text-align: center;
                    }
                    div:nth-child(2) {
                        font-size: 16px;
                        color: #666;
                        text-align: center;
                    }
                }
            }
            */
            .search-modal {
                background: #fff;
                padding: 20px 0 25px 18px;
                .btns {
                    width: 73px;
                    height: 40px;
                    text-align: center;
                    line-height: 40px;
                    color: #fff;
                    font-size: 14px;
                    border-radius: 4px;
                    background-color: #ED7018;
                    display: inline-block;
                    cursor: pointer;
                    &:hover{
                     background-color: #ED9000;
                     transition:all .2s linear
                    }
                }
                .btn-search {
                    margin: 0 20px 0 24px;
                }
                .search-item {
                    width: 25%;
                    display: inline-block;
                    /*margin-right: 2.56%;*/
                    &:last-child {
                        margin-right: 0;
                    }
                    .search-title {
                        display: inline-block;
                    }
                    .el-input {
                        display: inline-block;
                    }
                    .el-select {
                        width: 54%;
                    }
                }
            }
        }
    }
</style>
